﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace SysController
{
    public static class SupplierController
    {
        public static int ModifyIfNullAddSupplier(List<MODEL.Supplier> models)
        {
            foreach (var model in models)
            {
                SysHelper.OperateContext.CurrentContext.BllSession.ISupplier_BLL.ModifyIsNullADD(model, s => s.SupplierID == model.SupplierID, true, null);
            }
            
            return SysHelper.OperateContext.CurrentContext.BllSession.SaveChanges(typeof(MODEL.Supplier).ToString());
        }

        public static List<MODEL.Supplier> GetListByWhere(Expression<Func<MODEL.Supplier, bool>> whereLambda)
        {
            return SysHelper.OperateContext.CurrentContext.BllSession.ISupplier_BLL.GetListByWhere(whereLambda);
        }

        public static int DelSupplier(List<MODEL.Supplier> models)
        {
            foreach (var model in models)
            {
                SysHelper.OperateContext.CurrentContext.BllSession.ISupplier_BLL.Del(model);
            }
            
            return SysHelper.OperateContext.CurrentContext.BllSession.SaveChanges(typeof(MODEL.Supplier).ToString());
        }
    }
}
